import 'package:flutter/material.dart';
import 'package:hive/hive.dart';
import 'customTheme.dart';
import 'theme.dart';

class ThemePro with ChangeNotifier{
  ThemeData _themeData;
  CustomTheme _customTheme;
  Box _hiveBox;

  ThemeData get themeData => _themeData;
  CustomTheme get customTheme => _customTheme;

  init() async {
    _hiveBox = await Hive.openBox('theme');
    var theme = _hiveBox.get('themeName', defaultValue: 'light');
    _themeData = themeDataMap[theme];
    _customTheme = customThemeMap[theme];
  }

  changeTheme(String name) async {
    _themeData = themeDataMap[name];
    _customTheme = customThemeMap[name];
    _hiveBox.put('themeName', name);
    notifyListeners();
  }

}
